//
//  ZYHomeWorkManagerController.m
//  优学荟管理系统
//
//  Created by Ethan on 2017/9/22.
//  Copyright © 2017年 星道三好. All rights reserved.
//

#import "ZYHomeWorkManagerController.h"
#define kCell @"cell"
#import "ZYAssignmentController.h"
#import "ZYHomeWorkManagerCell.h"
#import "HNSetWorkVC.h"
@interface ZYHomeWorkManagerController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic,strong) NSMutableArray *dataSource;
@property (nonatomic,strong) NSMutableArray *dataSourceImageArray;
@property (nonatomic,strong) UITableView *tableView;
@end

@implementation ZYHomeWorkManagerController



- (NSMutableArray *)dataSourceImageArray {
    
    if (_dataSourceImageArray == nil) {
        self.dataSourceImageArray = [NSMutableArray arrayWithObjects:@"icon_assign_homework_default",@"icon_homework_condition_default",@"icon_commend_default",@"icon_fault_default", nil];
    }
    
    
    return _dataSourceImageArray;
}




- (NSMutableArray *)dataSource {
    
    if (_dataSource == nil) {
        self.dataSource = [NSMutableArray arrayWithObjects:@"布置作业",@"作业情况",@"作业评价",@"错题统计", nil];
    }
    
    return _dataSource;
}


- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = ColorRGB(247, 245, 245);
    self.title = @"作业管理";

    [self setUpSuperView];
}

- (void)setUpSuperView{
    
    
    UIView *allView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 15)];
    
    
    self.tableView = [[UITableView alloc]initWithFrame:CGRectMake(15, 0, SCREEN_WIDTH - 30, SCREENH_HEIGHT)];
    self.tableView.backgroundColor = ColorRGB(247, 245, 245);
    self.tableView.dataSource = self;
    self.tableView.delegate = self;
    [self.view addSubview:self.tableView];

    self.tableView.tableHeaderView = allView;
    self.tableView.tableFooterView = [UIView new];
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.tableView registerClass:[ZYHomeWorkManagerCell  class] forCellReuseIdentifier:kCell];
    
    
    
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    return self.dataSource.count;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    ZYHomeWorkManagerCell *cell = [tableView dequeueReusableCellWithIdentifier:kCell forIndexPath:indexPath];
    

    [cell.photoButton setImage:[UIImage imageNamed:self.dataSourceImageArray[indexPath.row]] forState:(UIControlStateNormal)];
    cell.homeWorkLabel.text = self.dataSource[indexPath.row];
    
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    
    
    
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

    if (indexPath.row == 0) {

        HNSetWorkVC *VC = [[HNSetWorkVC alloc] init];
        [self.navigationController pushViewController:VC animated:YES];

    } else {

        [self.navigationController pushViewController:[ZYAssignmentController new] animated:YES];
    }
}

@end
